package com.qf.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qf.pojo.Order;
import com.qf.pojo.Result;
import com.qf.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired
    private OrderService orderService;

    @GetMapping("/{currentPage}/{size}")
    public Result findAll(@PathVariable("currentPage") int currentPage, @PathVariable("size") int size){
        IPage<Order> page = new Page(currentPage, size);
        orderService.findByPage(page, Wrappers.emptyWrapper());

        List<Order> records = page.getRecords();
        System.out.println(records);

        return Result.success(page);
    }
}
